package com.study.samsung.Service;

import com.study.samsung.Dao.UserDAO;
import com.study.samsung.Entity.User;

import java.util.List;

public class UserService {
    UserDAO dao = new UserDAO();

    public Integer login(User user){
        User u = dao.selectByTel(user.getAccount());
        if (u==null){
            return -2;
        }else {
            if (u.getUpwd().equals(user.getUpwd())){
               if (u.isIsdel()==false){
                    return -3;
               }else {
                   user.setUid(u.getUid());
                   user.setNickname(u.getNickname());
                   user.setUname(u.getUname());
                   user.setSex(u.getSex());
                   user.setUphone(u.getUphone());
                   user.setBirth(u.getBirth());
                   user.setUpicture(u.getUpicture());
                   user.setAccount(u.getAccount());
                   user.setUpwd(u.getUpwd());
                   user.setIsdel(u.isIsdel());
                   return 1;
               }
            }else{
                return -1;
            }
        }
    }
    public Integer enroll(String nickname,
                          String uname,
                          String sex,
                          String uphone,
                          String birth,
                          String account,
                          String upwd){

        return dao.enroll(nickname,uname,sex,uphone,birth,account,upwd);
    }

  public User dophone(String uphone){
        return  dao.dophone(uphone);
  }
    public Integer doUpdate(User u){
        return dao.doUpdate(u);
    }


}
